<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as AuthUser;

// 引入软删除trait
use Illuminate\Database\Eloquent\SoftDeletes;

//引入自定义的trait  Btn 根据用户权限显示或隐藏权限按钮
use App\Models\Traits\Btn;

/**
 * App\Models\User
 *
 * @property int $id
 * @property int $role_id 角色ID
 * @property string $username 用户名
 * @property string $truename 真实姓名
 * @property string $password 密码
 * @property string|null $email 邮箱
 * @property string $phone 手机号码
 * @property string $gender 性别
 * @property string $last_ip 登录IP
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|User newQuery()
 * @method static \Illuminate\Database\Query\Builder|User onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|User query()
 * @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereEmail($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereGender($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereLastIp($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User wherePassword($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User wherePhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereRoleId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereTruename($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereUsername($value)
 * @method static \Illuminate\Database\Query\Builder|User withTrashed()
 * @method static \Illuminate\Database\Query\Builder|User withoutTrashed()
 * @mixin \Eloquent
 */
class User extends AuthUser
{
    // 调用定义好的trait 类 软删除  Btn
    use SoftDeletes, Btn;

    // 软删除表示字段
    protected $dates = ['deleted_at'];

    // 不添加的字段
    protected $guarded = [];
    // 隐藏字段
    protected $hidden = ['password'];

    // 多对一关联 角色表role
    public function role()
    {
        return $this->belongsTo(Role::class, 'role_id', 'id');
    }
}
